class BootStrap {
	// dependency injection
	def authenticateService
     def init = { servletContext ->
		 
		 def authority = new Role()
		 authority.authority = "ROLE_ADMIN"
		 authority.description ="I'm your boss"
		 authority.save()
		 authority = new Role()
		 authority.authority = "ROLE_TEAM"
		 authority.description ="Who am I?"
		 authority.save()
		 def user = new User()
		 user.username = "manager"
		 user.userRealName = "Paul"
		 user.passwd=authenticateService.encodePassword("1234")
		 user.pass="1234"
		 user.enabled = true
		 user.email="paul@cs.ait.ac.th"
		 user.emailShow=true
		 user.description="BOSSSSSSSS"
		 Role.findByAuthority("ROLE_ADMIN").addToPeople(user)
		 user.save()
		 user = new User()
		 user.username = "team"
		 user.userRealName = "Team Member"
		 user.passwd=authenticateService.encodePassword("1234")
		 user.pass="1234"
		 user.enabled = true
		 user.email="team@cs.ait.ac.th"
		 user.emailShow=true
		 user.description="TEAMMMMMM"
		 Role.findByAuthority("ROLE_TEAM").addToPeople(user)
		 user.save()
		 user = new User()
		 user.username = "team2"
		 user.userRealName = "Team Member2"
		 user.passwd=authenticateService.encodePassword("1234")
		 user.pass="1234"
		 user.enabled = true
		 user.email="team2@cs.ait.ac.th"
		 user.emailShow=true
		 user.description="TEAMMMMMM2"
		 Role.findByAuthority("ROLE_TEAM").addToPeople(user)
		 user.save()
		 def requestMap = new Requestmap()
		 requestMap.url = "/user/create"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/user/list"
		 requestMap.configAttribute = "ROLE_ADMIN,ROLE_TEAM"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/user/show/**"
		 requestMap.configAttribute = "ROLE_ADMIN,ROLE_TEAM"
		 requestMap.save()
		 requestMap.url = "/user/edit/**"
		 requestMap.configAttribute = "ROLE_ADMIN,ROLE_TEAM"
		 requestMap.save()
		 requestMap.url = "/user/delete/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/requestmap/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/task/create/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/task/edit/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/task/delete/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/project/create/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/project/edit/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/project/delete/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/subTask/create/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/subTask/edit/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/subTask/delete/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 requestMap = new Requestmap()
		 requestMap.url = "/projectTeam/**"
		 requestMap.configAttribute = "ROLE_ADMIN"
		 requestMap.save()
		 def project = new Project()
		 project.name = "BurnDownChart"
		 project.description = "Display Burn Down Chart"
		 project.startDate = new Date()
		 project.endDate = new Date()
		 project.unitOfWork = 10
		 project.unitPerPhase = 10
		 project.save()
		 def task = new Task()
		 task.name = "PSP0"
		 task.description = "PSP0"
		 task.startDate = new Date()
		 task.endDate = new Date()
		 task.endPlanDate = new Date()
		 task.hours = 10
		 task.numPhase =10
		 task.project = Project.get(1)
		 task.save()
		 def subtask = new SubTask()
		 subtask.phaseName = "Planning"
		 subtask.estimatedTime = 2
		 subtask.unitForPhase = 3
		 subtask.task = Task.get(1)
		 subtask.save()
		 subtask = new SubTask()
		 subtask.phaseName = "Design"
		 subtask.estimatedTime = 2
		 subtask.unitForPhase = 3
		 subtask.task = Task.get(1)
		 subtask.save()
		 subtask = new SubTask()
		 subtask.phaseName = "Code"
		 subtask.estimatedTime = 2
		 subtask.unitForPhase = 3
		 subtask.task = Task.get(1)
		 subtask.save()
		 subtask = new SubTask()
		 subtask.phaseName = "Test"
		 subtask.estimatedTime = 2
		 subtask.unitForPhase = 3
		 subtask.task = Task.get(1)
		 subtask.save()
		 def projectTeam = new ProjectTeam()
		 projectTeam.project = Project.get(1)
		 projectTeam.user = User.get(1)
		 projectTeam.save()
		 projectTeam = new ProjectTeam()
		 projectTeam.project = Project.get(1)
		 projectTeam.user = User.get(2)
		 projectTeam.save()
		 projectTeam = new ProjectTeam()
		 projectTeam.project = Project.get(1)
		 projectTeam.user = User.get(3)
		 projectTeam.save()
		 
     }
     def destroy = {
     }
} 
